<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>红豆恋-评价</title>
  <link href="./index.css" rel="stylesheet">
  <link rel="stylesheet" href="https://at.alicdn.com/t/font_604614_801vycf9m6l84cxr.css">
  <script>! function (n) {
    var e = n.document,
      t = e.documentElement,
      i = 750,
      d = i / 100,
      o = "orientationchange" in n ? "orientationchange" : "resize",
      a = function () {
        var n = t.clientWidth || 320;
        n > 750 && (n = 750);
        t.style.fontSize = n / d + "px"
      };
    e.addEventListener && (n.addEventListener(o, a, !1), e.addEventListener("DOMContentLoaded", a, !1))
  }(window);</script>
</head>
<body>
  <div class="comment" style="display: none">
    <div class="list-item comment-article">
    </div>
    <div class="comment-wrap">
    </div>
  </div>
  <script type="text/javascript" src="./fastclick.js" charset="utf-8"></script>
  <script type="text/javascript" src="./jquery.min.js" charset="utf-8"></script>
  <script type="text/javascript" src="./index.js" charset="utf-8"></script>
  <script>
    $(document).ready(function() {
      if (!location.search) {
        new Dialog({
          type: 'alert',
          msg: '没找到相关动态或征婚'
        })
        return false
      }
      var id = getUrlParam('id');
      $.ajax({
        url: 'https://WWW.hongdoulian.net/index.php/home/squares/read?t=1548641752971',
        type: 'post',
        data: {
          sqid: id
        },
        dataType: 'JSON',
        success: function(res) {
          if (res.code === 1) {
            var data = res.data;
            var gender = data.gender === '1' ? '男性' : '女性';
            var html = '<div class="list-item__avatar">' +
                      '<image src="' + data.headicon + '" />' +
                    '</div>' +
                    '<div class="list-middle">' +
                      '<div class="list-middle__title">' +
                        '<div class="left">' +
                          '<h2>' + data.nickname + '</h2>' +
                          '<span>' + gender + '</span>' +
                          '<span>' + data.saddress + '</span>' +
                          '<i class="offline">'+ data.opstatus + '</i>' +
                        '</div>' +
                        '<div class="list-middle__title--btn">' + '打招呼' + '</div>' +
                      '</div>' +
                      '<div class="list-middle__info">' +
                        '<span class="age">' + data.age + '岁</span>' +
                        '<span class="time">' + fomartTime(data.create_time) + '</span>' +
                      '</div>' +
                      '<div class="list-middle__content">';
            if (data.pics[0]) {
              html += '<div class="list-middle__content-img">';
              $.each(data.pics, function(index, item) {
                html += '<image src="' + item + '"/>';
              })
              html += '</div>';
            }
            html += '<div class="list-middle__content-text">' + data.contents + '</div>' +
                '</div>' +
            '</div>';
            console.log(html)
            $(".comment-article").append(html);
          } else {
            new Dialog({
              type: 'alert',
              msg: res.msg
            })
          }
        },

        error: function(error) {
          load.close()
          new Dialog({
            type: 'showMsg',
            msg: '网络错误'
          })
        }
      })
      
      var load = loading()
      $.ajax({
        url: 'https://WWW.hongdoulian.net/index.php/home/comments/getCommentsByid',
        type: 'POST',
        dataType: 'json',
        data: {
          sqid: id,
          page: 1,
          listrow: 20
        },
        success: function(res) {
          setTimeout(function(){
            $(".comment").show();
            load.close();
            if (res.code === 1) {
              var html = '';
              if (res.data.data.length) {
                $.each(res.data.data, function(index, item) {
                  html += '<div class="comment-list list-item">' +
                    '<image src="'+ item.headicon + '" />' +
                    '<div class="list-middle">' +
                      '<div class="list-middle__title">' +
                        '<div class="left">' +
                          '<h2>' + item.nickname + '</h2>' +
                        '</div>' +
                      '</div>' +
                      '<div class="list-middle__info">' +
                        '<span class="age">' + fomartTime(item.create_time) +'</span>' +
                      '</div>' +
                      '<div class="list-middle__content">' +
                        '<div class="list-middle__content-text">' + item.contents + '</div>' +
                      '</div>' +
                    '</div>' +
                  '</div>';
                })
                $(".comment-wrap").append(html);
              }
            } else {
              new Dialog({
                type: 'alert',
                msg: res.msg
              })
            }
          }, 500)
        },
        error: function(error) {
          load.close()
          new Dialog({
            type: 'showMsg',
            msg: '网络错误'
          })
        }
      })
    })
  </script>
</body>
</html>